<?php
/**
 * 数据库备份
 */
namespace app\admin\controller;

use think\Controller;
use think\Request;
use think\facade\Env;
use think\facade\Config;
class Backup extends Common
{
    /**
     * 显示资源列表
     *
     * @return \think\Response
     */
    public function index()
    {
        $type=input("tp");
        $name=input("name");
        $sql=new \org\Baksql(Config::get('database.'));//传入数据库整个配置
        switch ($type)
         {
         case "backup": //备份
           return $sql->backup();
           break;  
         case "dowonload": //下载
           $sql->downloadFile($name);
           break;  
         case "restore": //还原
           return $sql->restore($name);
           break; 
         case "del": //删除
           return $sql->delfilename($name);
           break;          
         default: //获取备份文件列表
         $list=$sql->get_filelist();
         $this->assign('list',$list);
          return view(); 
         }
    }

    
}
